const Generator = require('yeoman-generator')

module.exports = class extends Generator {
    prompting() {
        return this.prompt([
            {
                type: 'input',
                name: 'name',
                message: 'Your project name',
                default: this.appname  //appname为项目生成目录名称
            }
        ]).then(answers => {
           
            this.answers = answers
        })
    }
    writing() {
        //把每一个文件都通过模板转换到目标路径

        const templetes = [
            '.gitignore',                                                                        
            'babel.config.js',
            'package-lock.json',
            'package.json',
            'README.md',
            'src/App.vue',
            'src/main.js',                                                                               
            'src/router/index.js',
            'src/store/index.js',
        ]
    
        templetes.forEach(item => {
            this.fs.copyTpl(
                this.templatePath(item),
                this.destinationPath(item),
                this.answers
            )
        })
    }
}